from setuptools import setup
import os
from glob import glob

package_name = 'agv_debug_tool'

# 获取 scripts 目录下的所有文件
def get_scripts_files():
    data_files = []
    for dirpath, dirnames, filenames in os.walk('scripts'):
        if '__pycache__' in dirpath:
            continue
        dest_dir = os.path.join('lib', package_name, dirpath)
        files = [os.path.join(dirpath, f) for f in filenames]
        if files:
            data_files.append((dest_dir, files))
    return data_files

setup(
    name=package_name,
    version='0.0.1',
    packages=[package_name],
    data_files=[
        ('share/ament_index/resource_index/packages',
            ['resource/' + package_name]),
        ('share/' + package_name, ['package.xml']),
        # 确保所有 launch 文件被安装
        ('share/' + package_name + '/launch', glob('launch/*.*')),
    ] + get_scripts_files(),
    install_requires=['setuptools'],
    zip_safe=True,
    maintainer='haibo',
    maintainer_email='haibo@lgmgim.cn',
    description='Debug tool for AGV',
    license='TODO: License declaration',
    entry_points={
        'console_scripts': [
            'manage = scripts.manage:main'
        ],
    },
)